# lab10-1

filename = "learning_python.txt"

print("---->test1: 读取整个文件")
with open(filename) as target:
    object = target.read()
    print(object.strip())

print("\n---->test2：遍历文件对象")
with open(filename) as target:
    for object in target:
        print(object.strip())



print("\n---->test3: 存储各行到文件列表中, 在'with'代码块外访问内容")
with open(filename) as target:
    lines = target.readlines()

for line in lines:
    print(line.strip())
